const express = require("express");

const router = express.Router();
// 导入验证数据合法性的中间件
const expressJoi = require("@escook/express-joi");
// 导入需要的验证规则对象
const {
  update_userinfo_schema,
  update_password_schema,
} = require("../schema/user");
const { update_avatar_schema } = require("../schema/user");

// 导入信息处理模块
const userinfo_handler = require("../router_handler/userinfo");

router.get("/userinfo", userinfo_handler.getUserInfo);
router.post(
  "/updateUserInfo",
  expressJoi(update_userinfo_schema),
  userinfo_handler.updateUserInfo
);
router.post(
  "/updatePwd",
  expressJoi(update_password_schema),
  userinfo_handler.updatePwd
);
// 更新用户头像的路由
router.post(
  "/update/avatat",
  expressJoi(update_avatar_schema),
  userinfo_handler.updateAvatar
);

module.exports = router;
